﻿
// FilmServerDlg.h: 头文件
//

#pragma once

#include "PrinterCfg.h"
#include <thread>


// CFilmServerDlg 对话框
class CFilmServerDlg : public CDialogEx
{
// 构造
public:
	CFilmServerDlg(CWnd* pParent = nullptr);	// 标准构造函数

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_FILMSERVER_DIALOG };
#endif

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持


// 实现
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg void OnBnClickedButtonStart();
	afx_msg void OnBnClickedButtonClear();
	afx_msg void OnSelchangeComboPrinter();
	afx_msg void OnSelchangeComboLl();
	afx_msg LRESULT OnAddLog(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnServerStop(WPARAM wParam, LPARAM lParam);
	afx_msg void OnDestroy();
	DECLARE_MESSAGE_MAP()

private:
	int ReadPrinterCfg(const char* cfg);
	void addLog(LPCTSTR format, ...);

	int Start();
	int Stop();

	HANDLE m_hReadPipe = NULL;
	HANDLE m_hWritePipe = NULL;
	PROCESS_INFORMATION   m_pi = { 0 };
	std::thread m_thPipe;
	BOOL m_bStop = TRUE;
private:

	PrinterCfg::DcmPrinterVec m_printers;
	CEdit m_log;
	CComboBox m_cmbPrinter;
	CString m_Port;
	CString m_selPrinter;
	CComboBox m_cmbLL;

	CBrush m_brBlack;
	
public:
	int m_loglevel;
};
